﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Xml.Linq;
using System.Data;
using UniCT.LinkShareWpf.Interface;
using System.Xml.Serialization;
using System.Xml;
using System.IO;
using System.Collections.ObjectModel;
using System.ComponentModel;
using LinkShareWpf.ViewModel;


namespace LinkShareWpf
{
    /// <summary>
    /// Interaction logic for HomeWindow.xaml
    /// </summary>
    public partial class HomeWindow : Window
    {

        // Behind-Code is not EVIL!
        public HomeWindow()
        {
            InitializeComponent();
            (DataContext as HomeWindowViewModel).ChangeUserControlCommandRequested += ChangeUserControl;
            (DataContext as HomeWindowViewModel).ExitCommandRequested += delegate { Close(); };
        }

        private void ChangeUserControl(object sender, EventArgs e)
        {
            body_Grid.Content = (e as ParameterEventArgs).typeOfUserControl;
        }
       
        private void HomeWindow_Closing(object sender, CancelEventArgs e)
        {
            if (MessageBox.Show("Uscire dall'applicazione?", "Conferma d'uscita", MessageBoxButton.YesNo) == MessageBoxResult.No)
                    e.Cancel = true;
        }

    }

}
